/**
 * 添加展期弹窗控制器
 */
import tem from './index.html'
import './index.less'
import $_fn from '~plugins'
class defersCtrl {
  constructor($scope,$rootScope,http,$ui,$state,$location,$timeout) {
    $scope.param = {}
    $scope.redErr = {}
    $scope.cancel = function () {
      $rootScope.$uiDirectiveModal.close() //关闭方法
    }
    console.log($scope.params)
    $scope.param1={
    	oid:$scope.params.id
    }
    //提交参数
    $scope.param2={
    	oid:$scope.params.oid,
    	r_interest:$scope.params.r_interest,
    	sumP:$scope.params.sumP,
    	sumNumn:$scope.params.sumNumn,
    	sumNum:$scope.params.sumNum,
    	remarks:$scope.params.remarks,
    	update_type:$scope.params.update_type
    }
    $scope.param3={
    	apply_money:$scope.params.apply_money,
    	periods:$scope.params.periods
    }
    //获取订单信息
    /*$scope.xinXi=function(){
  	  		http.post('selectRenewalRead.do',$scope.param1,function (data) {
				if(data.errcode==1){
					$ui.toast({
						text:data.errmsg,
						type:'succeed',
						appendTo:'.defers'
					})
					$scope.order=data.data
					$scope.$apply()
				}else{
					$ui.toast({
						text:data.errmsg,
						type:'warning',
						appendTo:'.defers'
					})
				}
	        },function(_data){
	            console.log(_data);//报错
	      	})
  	  }
  	  $scope.xinXi()*/
    $scope.tiJiao1=function () {
    	console.log('添加展期')
      http.post('addRollover.do',$scope.param2,function (data) {
        if(data.errcode == 1){
        	$scope.cancel()
        	
          /*$scope.successToast(data.errmsg)
          $scope.cancel()
          $timeout(function(){
            window.location.reload()
          },1000)*/
          
        }else{
          /*$scope.errorToast(data.errmsg || '提交失败！')*/
        }
      })
    }
  }
}


defersCtrl.$inject = ['$scope','$rootScope','http','$ui','$state','$location','$timeout','$interval']
module.exports = angular.module('directive.defers', []).directive('defers', function() {
  return {
    restrict: 'E',
    template: tem,
    replace:true,
    controller: defersCtrl,
    scope: {
      params: '<'
    },
    link:function(){
      $_fn.clickBind()
    }
  }
}).name